<template>
  <a-modal
    title="新增子账户"
    :visible="visible"
    @ok="onSubmit"
    @cancel="onCancel"
  >
    <this-form ref="form" />
  </a-modal>
</template>
<script>
import thisForm from './form.vue'
export default {
  components: { thisForm },
  data() {
    return {
      visible: false,
      // row: null,
    }
  },
  methods: {
    open() {
      this.visible = true
    },
    onSubmit() {
      this.$refs.form.onSubmit((form) => {
        this.axios.post('/a/sub-admins/add', form).then((res) => {
          if (res.data.code === 1) {
            this.$refs.form.reset()
            this.visible = false
            this.$message.success('新增成功')
            this.$emit('refresh')
          } else {
            this.$message.error(res.data.msg)
          }
        })
      })
      return
    },
    onCancel() {
      // Object.assign(this.form, this.row)
      this.visible = false
    },
  },
}
</script>
